package 牛客网_N.动态规划.魔术索引_2;
/**
 * 非递归
 */
import java.util.Scanner;

public class Main2 {
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		int n = Integer.parseInt(in.nextLine());
		String str = in.nextLine();
		String[] dataStr = str.split(" ");
		int[] a = new int[n];
		for(int i = 0; i < n; i++){
			a[i] = Integer.parseInt(dataStr[i]);
		}
		int mid = 0, start = 0, end = n;
		while(start < end){
			mid = (start+end)/2;
			if(a[mid] > mid){
				end = mid;
			}else if(a[mid] < mid){
				start = mid;
			}else{
				System.out.println("true");
				return;
			}
		}
		System.out.println("false");
	}
}